<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>大屏渲染</title>
  <link rel="stylesheet" href="../static/css/atom.css">
  <style>
    .screen-wrapper {
      position: relative;
      z-index: 3;
    }

    .label {
      padding: 4px;
      background-color: rgba(255, 255, 255, 0.7);
      border-radius: 4px;
      font-size: 14px;
      pointer-events: auto;
    }
  </style>
</head>

<body>

  <div class="screen-wrapper">
    <div class="three-box" id="three-box"></div>
  </div>

  <div id="scene-container"></div>

  <script type="importmap">
    {
        "imports": {
        "three": "../three/v170/three.module.min.js",
        "three/addons/": "../three/v170/"
        }
    }
    </script>

  <script type="module">
    import * as THREE from 'three';
    import { CSS2DRenderer, CSS2DObject } from "three/addons/renderers/CSS2DRenderer.js";
    import { CSS3DRenderer, CSS3DObject } from "three/addons/renderers/CSS3DRenderer.js";
    import { TrackballControls } from 'three/addons/controls/TrackballControls.js';
    import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
    import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
    import { DragControls } from 'three/addons/controls/DragControls.js';
    import { GUI } from 'three/addons/libs/lil-gui.module.min.js';

    console.log(`[THREE版本]`, THREE.REVISION);

    // 创建场景
    const scene = new THREE.Scene();

    // 创建相机
    const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
    camera.position.z = 5;

    // 创建渲染器
    const renderer = new THREE.WebGLRenderer();
    renderer.setSize(window.innerWidth, window.innerHeight);
    document.body.appendChild(renderer.domElement);

    // 创建一个立方体
    const geometry = new THREE.BoxGeometry(1, 1, 1);
    // 创建不同颜色的材质
    const materials = [
      new THREE.MeshBasicMaterial({ color: 0xff0000 }), // 红色
      new THREE.MeshBasicMaterial({ color: 0x00ff00 }), // 绿色
      new THREE.MeshBasicMaterial({ color: 0x0000ff }), // 蓝色
      new THREE.MeshBasicMaterial({ color: 0xffff00 }), // 黄色
      new THREE.MeshBasicMaterial({ color: 0xff00ff }), // 品红色
      new THREE.MeshBasicMaterial({ color: 0x00ffff })  // 青色
    ];
    // const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
    const cube = new THREE.Mesh(geometry, materials);
    scene.add(cube);

    // 创建 DragControls
    const dragControls = new DragControls([cube], camera, renderer.domElement);

    // 渲染循环
    function animate() {
      requestAnimationFrame(animate);

      // 更新 DragControls
      dragControls.update();

      // 渲染场景
      renderer.render(scene, camera);
    }
    animate();

  </script>


</body>

</htm